package com.huanwei.questionfragment.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.huanwei.cc.R;
import com.huanwei.cc.base.Base_Z_Adapter;
import com.huanwei.cc.base.MyApplication;
import com.huanwei.cc.bean.FanKui;
import com.huanwei.cc.bean.Life_Login_UserInfo;
import com.huanwei.cc.bean.Life_MSG2;
import com.huanwei.cc.ui.EditTextDialog3;
import com.huanwei.questionfragment.FK_Activity;
import com.huanwei.questionfragment.Yh_Activity;


/**
 * Created by 他的猫 on 2016/12/3.
 * 待回答适配器
 */

public class fk_Adapter extends Base_Z_Adapter {
    fk_Adapter.Holder holder;
    FK_Activity activity;

    public void setactivity(FK_Activity activity) {
        this.activity = activity;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

        // 查找控件
        if (null == convertView) {
            convertView = LayoutInflater.from(MyApplication.getInstance())
                    .inflate(R.layout.item_fk, null);
            holder = new fk_Adapter.Holder();
            holder.name = (TextView) convertView
                    .findViewById(R.id.name);
            holder.xueke = (TextView) convertView
                    .findViewById(R.id.xueke);

            holder.shijian = (TextView) convertView
                    .findViewById(R.id.shijian);
            holder.word = (TextView) convertView
                    .findViewById(R.id.word);


            // 缓存Holder
            convertView.setTag(holder);
        } else {
            holder = (fk_Adapter.Holder) convertView.getTag();
        }
        final FanKui teacher = (FanKui) mDataList.get(position);

        holder.name.setText(teacher.getName());
        holder.word.setText(teacher.getMSG());
        holder.xueke.setText(teacher.getTime());
//        holder.bt_hf.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Life_MSG2 item = (Life_MSG2) getItem(position);
//                shareDialog(item.getTitle(), item.getTime());
//            }
//        });
        return convertView;
    }

    public class Holder {
        TextView name;
        TextView xueke;
        TextView shijian;
        TextView word;


    }

    private void shareDialog(String name, String zhiye) {

        EditTextDialog3 dialog = new EditTextDialog3(name, zhiye);
        dialog.show(activity.getSupportFragmentManager());
    }

}
